home *** CD-ROM | disk | FTP | other *** search
- page ,132
- ; KEYIN.COM
- ; Dan Rollins 2/11/83
- ; Personal Computer Age, Vol 2.8, August 1983, p. 16-21.
- ; This Program places up to 15 parameter characters into the
- ; IBM PC keyboard buffer for the program to read.
- ;
- ; Note: does not enter the space before the characters and
- ; does not place the end of text delimiter.
- ; Use `~' (tilde) to enter a CR (0DH).
- ;
- ; Example:
- ;
- ; KEYIN 1~a:myfile.txt~
- ; BASIC menu
- ;
- ; This will run the BASIC program `menu.bas', answer the
- ; first prompt with `1' [enter], and answer the next prompt
- ; with `a:myfile.txt' [enter]
- ;
- ; define the labels for the assembler
-
- bios_data segment at 40h
- org 1ah
- buf_head label word
-
- org 1ch
- buf_tail label word
-
- org 1eh
- kb_buf label word
- bios_data ends
-
- page
- cseg segment
- assume cs:cseg, ds:nothing, es:bios_data
-
- keyin proc far
-
- cli ;turn interrupts off
- mov cx,bios_data ;
- mov es,cx ;use ES as dest. segment
- mov word ptr es:buf_head, offset kb_buf
- mov di,offset kb_buf ;destination => buffer
- mov si,80h
- mov cl,[si]
- xor ch,ch ;cx = count of chars
- cmp cl,16
- jbe k1
- mov cl,16 ;if length > 16 then = 16
- k1:
- cmp cl,1 ;if length < 2
- jbe k_exit ; then do nothing;
- dec cx ;adjust for the space
- mov bx,cx ;copy length in words
- add bx,bx ; bx = length in bytes
- add bx,offset kb_buf ; bx = value for buf_tail
- inc si ;point past space
- inc si ; to first character
- mov ah,0 ;scan code = 0 (dummy)
- k2:
- lodsb ;set al=[si++]
- cmp al,'~' ;do we have a tilde?
- jne k3 ;use the char if not
- mov al,0dh ;use CR instead if tilde
- k3:
- stosw ;[di++]=al, [di++]=0
- loop k2 ;do for the entire string
-
- mov es:[buf_tail],bx ;now indicate the length
- k_exit:
- sti ;interrupts back on
- int 20h ;exit to DOS
-
- keyin endp
- cseg ends
-